package com.atsmart.app.utils;

import com.atsmart.app.BizApp;

import android.content.SharedPreferences;

/**
 * @author hubiao
 * 
 */
public class PrefsUtils {
	public static final int INVALID_NOTIFICATION_INDEX = -1;
	// 注册手机号码
	private static final String REGISTERED_PHONE_NUMBER = "registered_phone_number";
	private static final String REPORT_IMAGE_PATH = "report_img_path";
	private static final String LAST_MSG_DATE = "last_msg_date";
	private static final String REPORT_RECORD_PATH = "record_path";
	private static final String REPORT_CODE_VALUE = "code_value";
	private static final String REPORT_CODE_TYPE = "code_type";
	private static final String REPORT_IMAGE_PATH_ONE = "report_img_path_one";
	private static final String CLIENT_ID_NAME = "client_id_name";
	// 手机IMSI
	private static final String REGISTERED_IMSI = "registered_imsi";
	// 是否跳转到功能菜单界面,当启动时无网络，不进入，当用户失效或异常时不进入
	private static final String USER_STATE = "user_state";

	private static final SharedPreferences prefs = BizApp.getInstance()
			.getSharedPreferences("smart_prefs", 0);

	
	private static final String sub_tab = "sub_tab";
	public static void setSubTab(int val){
		prefs.edit().putInt(sub_tab, val).commit();
	}
	public static int getSubTab() {
		return prefs.getInt(sub_tab, 0);
	}

	
	/**
	 * 设置注册手机号码
	 * 
	 * @param val
	 */
//	public static void setRegisteredPhone(String val) {
//		prefs.edit().putString(REGISTERED_PHONE_NUMBER, val).commit();
//	}

	/**
	 * 返回注册手机号码
	 * 
	 * @return
	 */
//	public static String getRegisteredPhone() {
//		return prefs.getString(REGISTERED_PHONE_NUMBER, null);
//	}

	public static void setReportImagePath(String val) {
		prefs.edit().putString(REPORT_IMAGE_PATH, val).commit();
	}

	public static String getReportImagePath() {
		return prefs.getString(REPORT_IMAGE_PATH, null);
	}
	
	private static final String img = "img";
	public static void setImg(String val) {
		prefs.edit().putString(img, val).commit();
	}
	public static String getImg() {
		return prefs.getString(img, null);
	}

	private static final String imgs = "imgs";
	public static void setImgs(String val) {
		prefs.edit().putString(imgs, val).commit();
	}
	public static String getImgs() {
		return prefs.getString(imgs, null);
	}


	public static String getLastMsgDate() {
		return prefs.getString(LAST_MSG_DATE, null);
	}

	public static void setLastMsgDate(String dateString) {
		prefs.edit().putString(LAST_MSG_DATE, dateString).commit();
	}

	public static String getReportRecordPath() {
		return prefs.getString(REPORT_RECORD_PATH, null);
	}

	
	public static void setReportRecordPath(String val) {
		prefs.edit().putString(REPORT_RECORD_PATH, val).commit();
	}

	public static String getReportCodeValue() {
		return prefs.getString(REPORT_CODE_VALUE, null);
	}

	public static void setReportCodeValue(String val) {
		prefs.edit().putString(REPORT_CODE_VALUE, val).commit();
	}

	public static String getReportCodeType() {
		return prefs.getString(REPORT_CODE_TYPE, null);
	}

	public static void setReportCodeType(String val) {
		prefs.edit().putString(REPORT_CODE_TYPE, val).commit();
	}

	public static String getReportImagePathOne() {
		return prefs.getString(REPORT_IMAGE_PATH_ONE, null);
	}

	public static void setReportImagePathOne(String val) {
		prefs.edit().putString(REPORT_IMAGE_PATH_ONE, val).commit();
	}

	public static String getClientIdName() {
		return prefs.getString(CLIENT_ID_NAME, null);
	}

	public static void setClientIdName(String val) {
		prefs.edit().putString(CLIENT_ID_NAME, val).commit();
	}

	/**
	 * 返回手机IMSI
	 * 
	 * @return
	 */
//	public static String getRegisteredImsi() {
//		return prefs.getString(REGISTERED_IMSI, null);
//	}
//
//	/**
//	 * 设置手机IMSI
//	 * 
//	 * @param val
//	 */
//	public static void setRegisteredImsi(String val) {
//		prefs.edit().putString(REGISTERED_IMSI, val).commit();
//	}

	/**
	 * @return 返回用户当前状态
	 */
	public static String getUserState() {
		return prefs.getString(USER_STATE, null);
	}

	/**
	 * 设置用户当前状态
	 * 
	 * @param val
	 */
	public static void setUserState(String val) {
		if (!prefs.contains(USER_STATE)) {
			prefs.edit()
					.putString(
							USER_STATE,
							String.valueOf(PersistentKeyUtil.UN_NORMAL_USER_STATE))
					.commit();
		}
		prefs.edit().putString(USER_STATE, val).commit();
	}

	private static final String CELL_MSG = "location_msg";
	public static String getCellMsg() {
		return prefs.getString(CELL_MSG, null);
	}

	public static void setCellMsg(String val) {
		prefs.edit().putString(CELL_MSG, val).commit();
	}

	private static final String IMAGE_FILE = "image_file";

	public static String getImageFile() {
		return prefs.getString(IMAGE_FILE, null);
	}

	public static void setImageFile(String val) {
		prefs.edit().putString(IMAGE_FILE, val).commit();
	}

	private static final String result = "result_s";
	public static String getResult() {
		return prefs.getString(result, null);
	}
	public static void setResult(String val) {
		prefs.edit().putString(result, val).commit();
	}

	/** 推送消息ID */
	private static final String NOTIFICATION_ID = "message_ID";

	/** 取出推送消息ID */
	public static String getNotification() {
		return prefs.getString(NOTIFICATION_ID, null);
	}

	/** 设置推送消息ID */
	public static void setNotifiction(String val) {
		prefs.edit().putString(NOTIFICATION_ID, val).commit();
	}

	/** 是否推送通知标志位 */
	private static final String NOTI = "is_noti";

	/** 是否推送通知标志位 */
	public static String getIsNoti() {
		return prefs.getString(NOTI, null);
	}

	/** 是否推送通知标志位 */
	public static void setIsNoti(String val) {
		prefs.edit().putString(NOTI, val).commit();
	}

	/** 登陆时是否检测更新 */
	private static final String IS_PUSH_UP = "is_push_update";

	/** 登陆时是否检测更新 */
	public static String getIsPushUp() {
		if (prefs.contains(IS_PUSH_UP)) {
			return prefs.getString(IS_PUSH_UP, null);
		} else {
			return null;
		}
	}

	/** 登陆时是否检测更新 */
	public static void setIsPushUp(String val) {
		prefs.edit().putString(IS_PUSH_UP, val).commit();
	}
	
	private static final String IMAGE = "is_cut";
	public static String getIsCut() {
		return prefs.getString(IMAGE, null);
	}
	public static void setIsCut(String val) {
		prefs.edit().putString(IMAGE, val).commit();
	}
	
	private static final String HASE_ROATE = "hase_roate";
	public static String getHaseRote() {
		return prefs.getString(HASE_ROATE, null);
	}
	public static void setHaseRote(String val) {
		prefs.edit().putString(HASE_ROATE, val).commit();
	}
	
	private static final String PRODUCT_TYPE= "product_type";
	public static String getProductType() {
		return prefs.getString(PRODUCT_TYPE, null);
	}
	public static void setProductType(String val) {
		prefs.edit().putString(PRODUCT_TYPE, val).commit();
	}
	
	private static final String PRODUCT_VALUE= "product_value";
	public static String getProductValue() {
		return prefs.getString(PRODUCT_VALUE, null);
	}
	public static void setProductValue(String val) {
		prefs.edit().putString(PRODUCT_VALUE, val).commit();
	}
	
	private static final String last_time= "last_time";
	public static String getLastTime() {
		return prefs.getString(last_time, null);
	}
	public static void setLastTime(String val) {
		prefs.edit().putString(last_time, val).commit();
	}
	
	private static final String last_data= "last_data";
	public static String getLastData() {
		return prefs.getString(last_data, null);
	}
	public static void setLastData(String val) {
		prefs.edit().putString(last_data, val).commit();
	}
	
	private static final String last_loc_data= "last_loc_data";
	public static String getLastLocData() {
		return prefs.getString(last_loc_data, null);
	}
	public static void setLastLocData(String val) {
		prefs.edit().putString(last_loc_data, val).commit();
	}
	
	private static final String lastType= "last_type";
	public static String getLastType() {
		return prefs.getString(lastType, null);
	}
	public static void setLastType(String val) {
		prefs.edit().putString(lastType, val).commit();
	}
	
	private static final String URL= "URL";
	public static String getURL() {
		return prefs.getString(URL, null);
	}
	public static void setURL(String val) {
		prefs.edit().putString(URL, val).commit();
	}
	
	private static final String isImsi= "isImsi";
	public static String getIsImsi() {
		return prefs.getString(isImsi, null);
	}
	public static void setIsImsi(String val) {
		prefs.edit().putString(isImsi, val).commit();
	}
	
	private static final String isHighPic= "isHighPic";
	public static String getIsHighPic() {
		return prefs.getString(isHighPic, null);
	}
	public static void setIsHighPic(String val) {
		prefs.edit().putString(isHighPic, val).commit();
	}
}
